package com.e3.basdoc.employee.model;

import java.util.Date;

import com.e3.basdoc.bank.model.BankModel;
import com.e3.basdoc.dept.model.DeptModel;
import com.e3.basdoc.employeecls.model.EmployeeClsModel;
import com.e3.core.lang.DataConstants;
import com.e3.web.core.model.SuperModel;

public class EmployeeModel extends SuperModel implements EmployeeFields {

	private static final long serialVersionUID = 5039315291871342703L;

	private String code;

	private String name;

	private String formerName;

	private Long deptId;

	private DeptModel dept;

	private Integer gender;

	private String idcardNo;

	private Date birthday;

	private String email;

	private String homePhone;

	private String homeAddress;

	private String homePostcode;

	private String mobile;

	private String officePhone;

	private Date workFromDate;

	private Integer education;

	private Long classesId;

	private EmployeeClsModel classes;

	private Date onboardDate;

	private Date quitDate;

	private Long bankId;

	private BankModel bank;

	private String bankAccount;

	private String skillLevel;

	private String rank;

	private String remark;
	
	private Integer status;

	public String getCode() {
		return get(EmployeeModel.CODE);
	}

	public void setCode(String code) {
		set(EmployeeModel.CODE,code);
	}

	public String getName() {
		return get(EmployeeModel.NAME);
	}

	public void setName(String name) {
		set(EmployeeModel.NAME,name);
	}

	public String getFormerName() {
		return get(EmployeeModel.FORMER_NAME);
	}

	public void setFormerName(String formerName) {
		set(EmployeeModel.FORMER_NAME,formerName);
	}

	public Long getDeptId() {
		if(deptId == null){
			return getRefModelId(EmployeeModel.DEPT);
		}
		return deptId;
	}

	public void setDeptId(Long deptId) {
		this.deptId = deptId;
	}

	public DeptModel getDept() {
		return get(EmployeeModel.DEPT);
	}

	public void setDept(DeptModel dept) {
		set(EmployeeModel.DEPT,dept);
	}

	public Integer getGender() {
		return getIntValue(EmployeeModel.GENDER,DataConstants.MALE);
	}

	public void setGender(Integer gender) {
		set(EmployeeModel.GENDER,gender);
	}

	public String getIdcardNo() {
		return get(EmployeeModel.IDCARD_NO);
	}

	public void setIdcardNo(String idcardNo) {
		set(EmployeeModel.IDCARD_NO,idcardNo);
	}

	public Date getBirthday() {
		return get(EmployeeModel.BIRTHDAY);
	}

	public void setBirthday(Date birthday) {
		set(EmployeeModel.BIRTHDAY,birthday);
	}

	public String getEmail() {
		return get(EmployeeModel.EMAIL);
	}

	public void setEmail(String email) {
		set(EmployeeModel.EMAIL,email);
	}

	public String getHomePhone() {
		return get(EmployeeModel.HOME_PHONE);
	}

	public void setHomePhone(String homePhone) {
		set(EmployeeModel.HOME_PHONE,homePhone);
	}

	public String getHomeAddress() {
		return get(EmployeeModel.HOME_ADDRESS);
	}

	public void setHomeAddress(String homeAddress) {
		set(EmployeeModel.HOME_ADDRESS,homeAddress);
	}

	public String getHomePostcode() {
		return get(EmployeeModel.POSTCODE);
	}

	public void setHomePostcode(String homePostcode) {
		set(EmployeeModel.POSTCODE,homePostcode);
	}

	public String getMobile() {
		return get(EmployeeModel.MOBILE);
	}

	public void setMobile(String mobile) {
		set(EmployeeModel.MOBILE,mobile);
	}

	public String getOfficePhone() {
		return get(EmployeeModel.OFFICE_PHONE);
	}

	public void setOfficePhone(String officePhone) {
		set(EmployeeModel.OFFICE_PHONE,officePhone);
	}

	public Date getWorkFromDate() {
		return get(EmployeeModel.WORK_FROM_DATE);
	}

	public void setWorkFromDate(Date workFromDate) {
		set(EmployeeModel.WORK_FROM_DATE,workFromDate);
	}

	public Integer getEducation() {
		return getIntValue(EmployeeModel.EDUCATION, EmployeeEducations.EDU_OTHERS);
	}

	public void setEducation(Integer education) {
		set(EmployeeModel.EDUCATION,education);
	}

	public Long getClassesId() {
		if(classesId == null){
			return getRefModelId(EmployeeModel.CLASSES);
		}
		return classesId;
	}

	public void setClassesId(Long classesId) {
		this.classesId = classesId;
	}

	public EmployeeClsModel getClasses() {
		return get(EmployeeModel.CLASSES);
	}

	public void setClasses(EmployeeClsModel classes) {
		set(EmployeeModel.CLASSES,classes);
		if(classes == null){
			setClassesId(0L);
		}
		else{
			setClassesId(classes.getId());
		}
	}

	public Date getOnboardDate() {
		return get(EmployeeModel.ONBOARD_DATE);
	}

	public void setOnboardDate(Date onboardDate) {
		set(EmployeeModel.ONBOARD_DATE,onboardDate);
	}

	public Date getQuitDate() {
		return get(EmployeeModel.QUIT_DATE);
	}

	public void setQuitDate(Date quitDate) {
		set(EmployeeModel.QUIT_DATE,quitDate);
	}

	public Long getBankId() {
		if(bankId == null){
			return getRefModelId(EmployeeModel.BANK);
		}
		return bankId;
	}

	public void setBankId(Long bankId) {
		this.bankId = bankId;
	}

	public BankModel getBank() {
		return get(EmployeeModel.BANK);
	}

	public void setBank(BankModel bank) {
		set(EmployeeModel.BANK,bank);
		if(bank==null){
			setBankId(0L);
		}
		else{
			setBankId(bank.getId());
		}
	}

	public String getBankAccount() {
		return get(EmployeeModel.BANK_ACCOUNT);
	}

	public void setBankAccount(String bankAccount) {
		set(EmployeeModel.BANK_ACCOUNT,bankAccount);
	}

	public String getSkillLevel() {
		return get(EmployeeModel.SKILL_LEVEL);
	}

	public void setSkillLevel(String skillLevel) {
		set(EmployeeModel.SKILL_LEVEL,skillLevel);
	}

	public String getRank() {
		return get(EmployeeModel.RANK);
	}

	public void setRank(String rank) {
		set(EmployeeModel.RANK,rank);
	}

	public String getRemark() {
		return get(EmployeeModel.REMARK);
	}

	public void setRemark(String remark) {
		set(EmployeeModel.REMARK,remark);
	}

	public Integer getStatus() {
		return getIntValue(EmployeeModel.STATUS,EmployeeStatus.STATUS_NORMAL);
	}

	public void setStatus(Integer status) {
		set(EmployeeModel.STATUS,status);
	}

	public String toString() {
		// String s = getShortName();
		// if(s == null||s.trim().length()==0){
		// s = getName();
		// }
		// return s;
		return getName();
	}

}
